package atm;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 菜单界面
 */
public class MenuPanel extends JPanel implements ActionListener {

    private ImageIcon saveImg  = new ImageIcon("Tu/buttonSave.jpg");
    private ImageIcon saveImg1 = new ImageIcon("Tu/buttonGet.jpg");
    private ImageIcon saveImg2 = new ImageIcon("Tu/buttonModify.jpg");
    private ImageIcon saveImg3 = new ImageIcon("Tu/buttonFind.jpg");
    private ImageIcon saveImg4 = new ImageIcon("转账");
    private Font font=new Font("正楷",Font.PLAIN,30);

    private ImageIcon saveImg5 = new ImageIcon("Tu/buttonOff.jpg");

    private JButton saveBtn  = new JButton(saveImg);
    private JButton saveBtn1 = new JButton(saveImg1);
    private JButton saveBtn2 = new JButton(saveImg2);
    private JButton saveBtn3 = new JButton(saveImg3);
    private JButton saveBtn4 = new JButton("转账");
    private JButton saveBtn5 = new JButton(saveImg5);
    private ATMFrame atmFrame;


    public MenuPanel(ATMFrame atmFrame){
        this.atmFrame = atmFrame;
        this.setLayout(null);
        saveBtn.setBounds(0, 150,140,50);
        saveBtn1.setBounds(0,250,140,50);
        saveBtn2.setBounds(0,350,140,50);
        saveBtn3.setBounds(884,150,140,50);
        saveBtn4.setBounds(884,250,140,50);
        saveBtn4 .setFont(font);
        saveBtn5.setBounds(884,350,140,50);
        saveBtn.addActionListener(this);
        saveBtn1.addActionListener(this);
        saveBtn2.addActionListener(this);
        saveBtn3.addActionListener(this);
        saveBtn4.addActionListener(this);



        this.add(saveBtn);
        this.add(saveBtn1);
        this.add(saveBtn2);
        this.add(saveBtn3);
        this.add(saveBtn4);
        this.add(saveBtn5);
        this.setOpaque(false);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (saveBtn==e.getSource()) {
            atmFrame.switchPanel("save");
        }else if (saveBtn1==e.getSource()){
            atmFrame.switchPanel("Get");
        }else if (saveBtn2==e.getSource()){
            atmFrame.switchPanel("changePwd");
        }else if (saveBtn3==e.getSource()){
            atmFrame.switchPanel("search");
        }else if (saveBtn4==e.getSource()){
            atmFrame.switchPanel("Transfer");
        }else if (saveBtn5==e.getSource()){
            atmFrame.switchPanel("");
        }

    }
}
